import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";

/**
 * Col.js
 * @date 2018/10/10
 */
import React from 'react';
import { Button } from 'antd';
import { fieldLabelProp } from "../../../config";
import CellControl from "./CellControl";
import styles from "../../index.less?modules";
var componentMap = {
  Button: Button
};

var Col = /*#__PURE__*/function (_React$Component) {
  _inherits(Col, _React$Component);

  var _super = _createSuper(Col);

  function Col() {
    _classCallCheck(this, Col);

    return _super.apply(this, arguments);
  }

  _createClass(Col, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          component = _this$props.component,
          pComponent = _this$props.pComponent,
          currentEditField = _this$props.currentEditField,
          wrapperFieldComponent = _this$props.wrapperFieldComponent,
          colOptions = _this$props.colOptions,
          onRemoveField = _this$props.onRemoveField;
      var ComponentType = componentMap[component.componentType] || Button;
      var props = {
        type: component.type
      };
      return /*#__PURE__*/React.createElement("div", {
        className: styles['dynamic-toolbar-item'],
        style: component.style || {}
      }, wrapperFieldComponent( /*#__PURE__*/React.createElement(CellControl, {
        component: component,
        pComponent: pComponent,
        currentEditField: currentEditField,
        fieldOptions: colOptions,
        onRemoveField: onRemoveField
      }, React.createElement(ComponentType, props, component[fieldLabelProp])), component, colOptions));
    }
  }]);

  return Col;
}(React.Component);

export { Col as default };